﻿/**
 * jQuery ligerUI 1.1.9
 * 
 * http://ligerui.com
 * 
 * Author daomi 2012 [ gd_star@163.com ]
 * 
 */
(function($){
  
  $.fn.ligerButton=function(options){
    return $.ligerui.run.call(this,"ligerButton",arguments);
  };
  $.fn.ligerGetButtonManager=function(){
    return $.ligerui.run.call(this,"ligerGetButtonManager",arguments);
  };
  
  $.ligerDefaults.Button={
    width:100,
    text:'Button',
    disabled:false
  };
  
  $.ligerMethos.Button={};
  
  $.ligerui.controls.Button=function(element,options){
    $.ligerui.controls.Button.base.constructor.call(this,element,options);
  };
  $.ligerui.controls.Button.ligerExtend($.ligerui.controls.Input,{
    __getType:function(){
      return 'Button';
    },
    __idPrev:function(){
      return 'Button';
    },
    _extendMethods:function(){
      return $.ligerMethos.Button;
    },
    _render:function(){
      var g=this,p=this.options;
      g.button=$(g.element);
      g.button.addClass("l-btn");
      g.button.append('<div class="l-btn-l"></div><div class="l-btn-r"></div><span></span>');
      p.click&&g.button.click(function(){
        if(!p.disabled)
        p.click.apply(g,arguments);
      });
      g.set(p);
    },
    _setDisabled:function(value){  //modify by franky
      this._setEnabled(value==true);
    },
    _setEnabled:function(value){  //modify by franky
      if(value){
	      this.button.removeClass("l-btn-disabled");
        $(this.button).attr("disabled",false);
	      this.button.disabled="";
	      this.options.disabled=false;
      }
      else{
	      this.button.addClass("l-btn-disabled");
	      $(this.button).attr("disabled",true);
	      this.options.disabled=true;
      }
         
    },
    enable:function(){  //add by franky
      this._setEnabled(true);  
    },
    disable:function(){
      this._setEnabled(false);  //add by franky
    },
    _setWidth:function(value){
      this.button.width(value);
    },
    _setText:function(value){
      $("span",this.button).html(value);
    },
    setValue:function(value){
      this.set('text',value);
    },
    getValue:function(){
      return this.options.text;
    },
    setEnabled:function(){  //modify by franky
      this.enable();
    },
    setDisabled:function(){  //modify by franky
      this.disable();
    }
  });
  
})(jQuery);